package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.business.domain.CzIcon;
import com.ruoyi.business.service.ICzIconService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 图标管理Controller
 * 
 * @author ruoyi
 * @date 2022-02-11
 */
@Api(tags = "图标管理")
@RestController
@RequestMapping("/business/icon")
public class CzIconController extends BaseController
{
    @Autowired
    private ICzIconService czIconService;

    /**
     * 查询图标管理列表
     */
    @ApiOperation(value = "查询图标管理列表")
    @PreAuthorize("@ss.hasPermi('business:icon:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzIcon czIcon)
    {
        startPage();
        List<CzIcon> list = czIconService.selectCzIconList(czIcon);
        return getDataTable(list);
    }

    /**
     * 导出图标管理列表
     */
    @ApiOperation(value = "导出图标管理列表")
    @PreAuthorize("@ss.hasPermi('business:icon:export')")
    @Log(title = "图标管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzIcon czIcon)
    {
        List<CzIcon> list = czIconService.selectCzIconList(czIcon);
        ExcelUtil<CzIcon> util = new ExcelUtil<CzIcon>(CzIcon.class);
        util.exportExcel(response, list, "图标管理数据");
    }

    /**
     * 获取图标管理详细信息
     */
    @ApiOperation(value = "获取图标管理详细信息")
    @PreAuthorize("@ss.hasPermi('business:icon:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(czIconService.selectCzIconById(id));
    }

    /**
     * 新增图标管理
     */
    @ApiOperation(value = "新增图标管理")
    @PreAuthorize("@ss.hasPermi('business:icon:add')")
    @Log(title = "图标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzIcon czIcon)
    {
        return toAjax(czIconService.insertCzIcon(czIcon));
    }

    /**
     * 修改图标管理
     */
    @ApiOperation(value = "修改图标管理")
    @PreAuthorize("@ss.hasPermi('business:icon:edit')")
    @Log(title = "图标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzIcon czIcon)
    {
        return toAjax(czIconService.updateCzIcon(czIcon));
    }

    /**
     * 删除图标管理
     */
    @ApiOperation(value = "删除图标管理")
    @PreAuthorize("@ss.hasPermi('business:icon:remove')")
    @Log(title = "图标管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(czIconService.deleteCzIconByIds(ids));
    }
}
